<template >
<view class="container">
   <div class="list" v-for="(val,index) in items" :key="index">
       <p class="title">  {{val.title}}  </p>
        <p>{{val.question}}</p>
        <p> <img :key="ind" v-for="(url,ind) in val.imgList" :src="url.imgUrl"  ><span class="span2">{{val.imgList.length}}个回答</span> <span class="span3">{{val.createTime}}</span> </p>
   </div>
</view>
</template>

<script>
import api from '@/utils/api'

export default {
  data () {
    return {
      topicList: [],
      page: 1,
      size: 10,
      count: 0,
      scrollTop: 0,
      showPage: false,
      items:[],
      loadingBt:false
    }
  },
  async mounted () {
    await Promise.all([
      this.getTopicList()
    ])
  },

  methods: {
    // 获取专题信息
    async getTopicList () {
       let data=JSON.stringify({"pageIndex":this.page,"pageSize":"10"})
      const res = await api.getQuestionList({"data":data});
      this.items = this.items.concat(res.data);
                   if (res.data.length == 10) {
                        this.page++;
                        this.loadingBt=true;
                    }else{
                        this.loadingBt=false;
                    }
    },
    // 上一页
    
  // 原生的分享功能
  onShareAppMessage: function () {
    return {
      title: 'dfcShop',
      desc: '大风车商场',
      path: '/pages/topic/topic'
    }
  }
},
onPullDownRefresh(){
 wx.stopPullDownRefresh();
},
   
  onReachBottom(){
    if(this.loadingBt){
        this.getTopicList()
    }
  
  },
}

</script>

<style lang='scss' scoped>
page ,.container{
   width: 750rpx;
    height: 100%;
    overflow: hidden;
    background: #f4f4f4;
}
 .list{
    width: 96vw;
    padding-left: 4vw;
    background: #fff;
    margin-top:15px;
    padding-bottom: 10px;
    p:nth-child(1){
        color:rgba(51,51,51,1);
        font-size: 15px;
        padding: 15px 0;

    }
        p:nth-child(2){

        font-size: 13px;
        margin-bottom: 15px ;
        text-overflow:ellipsis;
        display:-webkit-box;
        -webkit-line-clamp:1;
        -webkit-box-orient:vertical;
        height: 15px;;
        line-height: 15px;
        overflow:hidden;
        color: rgba(51,51,51,0.9);

    }
    p:nth-child(3){
        height: 20px;;
        line-height: 20px;
        font-size: 12px;
        color: rgba(51,51,51,0.6);
       img{
            display: block;
            float: left;
            width:20px ;
            height: 20px;
            margin-right: 5px;
        }
        .span2{
              float: left;
              margin-left: 5px
             
        }
        .span3{
        float: right;
            margin-right: 3vw;
        }
    
    }
 }
</style>
